#include<iostream>
#include<string>
const int N = 1e6 + 10;
int a[26], kind,mp[N];
using namespace std;
int main()
{
	string s1;cin >> s1;
	int left = 0, right = 0, ret = s1.size();
	while (right <= s1.size())
	{
		if (mp[s1[right] - 'a']++ == 0) kind++;
		while (kind == 26)
		{
			int len = right - left + 1;
			if (ret > len) ret = len;
			if (mp[a[left]]-- == 1) kind--;
			left++;
		}
		right++;
	}
	cout << ret << endl;
	return 0;
}